/**
 *
 * @authors wmn1525 (wmn1525@gmail.com)
 * @date    2020/08/21
 * @description 自适应 1rem = 100px
 */
!(function (doc, win) {
    var docEle = doc.documentElement,
        evt = "onorientationchange" in window ? "orientationchange" : "resize",
        setFontSize = function () {
            let width = docEle.offsetWidth;
            if (width) {
                if (parseInt(width) == 1920) {
                    docEle.style.fontSize = 625 + '%'
                } else {
                    docEle.style.fontSize = 16 * (parseInt(width) / 1920) * 6.25 + 'px'
                }
            }
        };
    // 调整窗口时重置
    win.addEventListener(evt, function () {
        clearTimeout(timer);
        var timer = setTimeout(setFontSize, 300);
    }, true);
    doc.addEventListener("DOMContentLoaded", setFontSize, false);
    // pageshow
    // keyword: 倒退 缓存相关
    win.addEventListener("pageshow", function (e) {
        if (e.persisted) {
            clearTimeout(timer);
            var timer = setTimeout(setFontSize, 300);
        }
    }, false);
}(document, window));
